// lib/pages/setting.dart
import 'package:flutter/material.dart';

class SettingsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('设置'),
        elevation: 0,
        backgroundColor: Colors.transparent,
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // 用户资料卡片
            _buildProfileCard(context),
            const SizedBox(height: 24),
            
            // 应用设置
            const Text(
              '应用设置',
              style: TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.bold,
                color: Color(0xFF232751),
              ),
            ),
            const SizedBox(height: 16),
            _buildSettingItem(
              context,
              icon: Icons.notifications_outlined,
              title: '通知设置',
              subtitle: '管理应用通知',
              iconColor: Colors.amber,
            ),
            _buildSettingItem(
              context,
              icon: Icons.language_outlined,
              title: '语言设置',
              subtitle: '简体中文',
              iconColor: Colors.blue,
            ),
            _buildSettingItem(
              context,
              icon: Icons.color_lens_outlined,
              title: '主题设置',
              subtitle: '默认主题',
              iconColor: Colors.purple,
            ),
            const SizedBox(height: 24),
            
            // 其他设置
            const Text(
              '其他',
              style: TextStyle(
                fontSize: 20,
                fontWeight: FontWeight.bold,
                color: Color(0xFF232751),
              ),
            ),
            const SizedBox(height: 16),
            _buildSettingItem(
              context,
              icon: Icons.help_outline,
              title: '帮助与反馈',
              subtitle: '反馈问题或获取帮助',
              iconColor: Colors.green,
            ),
            _buildSettingItem(
              context,
              icon: Icons.info_outline,
              title: '关于',
              subtitle: '应用版本 1.0.0',
              iconColor: Colors.grey,
            ),
          ],
        ),
      ),
    );
  }
  
  Widget _buildProfileCard(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(20),
      decoration: BoxDecoration(
        color: Theme.of(context).colorScheme.primary,
        borderRadius: BorderRadius.circular(16),
        boxShadow: [
          BoxShadow(
            color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
            blurRadius: 10,
            offset: const Offset(0, 4),
          ),
        ],
      ),
      child: Row(
        children: [
          // 头像
          CircleAvatar(
            radius: 35,
            backgroundColor: Colors.white.withOpacity(0.3),
            child: const Icon(
              Icons.person,
              size: 40,
              color: Colors.white,
            ),
          ),
          const SizedBox(width: 20),
          // 用户信息
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: const [
              Text(
                'Steven',
                style: TextStyle(
                  fontSize: 22,
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 4),
              Text(
                'steven@example.com',
                style: TextStyle(
                  fontSize: 14,
                  color: Colors.white70,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
  
  Widget _buildSettingItem(
    BuildContext context, {
    required IconData icon,
    required String title,
    required String subtitle,
    required Color iconColor,
  }) {
    return Container(
      margin: const EdgeInsets.only(bottom: 12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
        boxShadow: [
          BoxShadow(
            color: Colors.grey.withOpacity(0.1),
            blurRadius: 5,
            offset: const Offset(0, 2),
          ),
        ],
      ),
      child: ListTile(
        leading: Container(
          padding: const EdgeInsets.all(8),
          decoration: BoxDecoration(
            color: iconColor.withOpacity(0.1),
            shape: BoxShape.circle,
          ),
          child: Icon(icon, color: iconColor),
        ),
        title: Text(title),
        subtitle: Text(subtitle),
        trailing: const Icon(Icons.arrow_forward_ios, size: 16),
        onTap: () {},
      ),
    );
  }
}
